package ca.qc.bdeb.info.pp2.tp2.application;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

public class PieceDao
{
    public static List<Piece> listerPiece(int idHabitation)
    {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        Query query = session.createQuery("from Piece where idHabitation = :idHabitation order by niveau desc");
        query.setInteger("idHabitation", idHabitation);
        return (List<Piece>) (query.list());
    }
}
